/**
 * Copyright(c) 2014 Xunton Solutions
 *
 * History:
 *   15-12-18 上午10:20 Created by dwzhang
 */
package com.jade.bss.ec.order;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;

/**
 * 商城订单。
 *
 * @author <a href="mailto:dwzhang@xunton.com">dwzhang</a> 
 * @version 1.0 15-12-18 上午10:20
 */
@Entity
@Table (name = "BSS_EC_ORDER")
public class ECOrder implements Serializable
{
    //新建订单，未支付
    public static final int STATUS_NEW = 0;
    //订单已支付，等待出库
    public static final int STATUS_PAID = 1;
    //发送配送中心，可选
    public static final int STATUS_SEND_TO_DC = 2;
    //配送中心接收，可选
    public static final int STATUS_DC_RECEIVED = 3;
    //等待发货，可选
    public static final int STATUS_WAIT_DELIVERY = 4;
    //已发货，等待收货
    public static final int STATUS_WAIT_RECEIVED = 5;
    //用户已收货，订单完成
    public static final int STATUS_FINISHED = 6;
    //订单已取消，在支付前都可以取消
    public static final int STATUS_CANCELLED = 9;

    //货到付款
    public static final int PAY_TYPE_COD = 1;
    //邮局汇款
    public static final int PAY_TYPE_POST = 2;
    //在线支付
    public static final int PAY_TYPE_ONLINE = 3;
    //银行转账
    public static final int PAY_TYPE_BANK = 5;
    //公司转账
    public static final int PAY_TYPE_COMPANY = 5;

    //订单编号
    @Id
    @GeneratedValue (generator = "BSS_SEQ_EC_ORDER")
    @SequenceGenerator (name = "BSS_SEQ_EC_ORDER", sequenceName = "BSS_SEQ_EC_ORDER")
    private long id;
    //父订单编号
    @Column (name = "pid")
    private long pid;
    @Column (name = "type", nullable = false, updatable = false)
    //订单类型，根据业务需要而定
    private String type;
    //订单所有者类型
    @Column (name = "owner_type", length = 32, nullable = false, updatable = false)
    private String ownerType;
    //订单所有者
    @Column (name = "owner_id", length = 64, nullable = false, updatable = false)
    private String ownerId;
    //支付类型
    @Column (name = "pay_type", nullable = false)
    private int payType;
    //订单总金额，单位为元
    @Column (name = "total_price", nullable = false)
    private double totalPrice;
    //用户应付金额，单位为元
    @Column (name = "payment_price", nullable = false)
    private double paymentPrice;
    //订单货款（订单总金额-商家优惠金额），单位为元
    @Column (name = "seller_price", nullable = false)
    private double sellerPrice;
    //订单运费，单位为元
    @Column (name = "freight_price", nullable = false)
    private double freightPrice;
    //商家折扣，单位为元
    @Column (name = "seller_discount", nullable = false)
    private double sellerDiscount;
    //订单状态
    @Column (name = "status", nullable = false)
    private int status = STATUS_NEW;
    //收件人地址
    @Column (name = "consignee_address", nullable = false)
    private long consigneeAddress;
    //订单创建时间
    @Column (name = "creation_date", nullable = false)
    private Date creationDate;
    //订单更新时间
    @Column (name = "update_date")
    private Date updateDate;
    //订单结束时间
    @Column (name = "end_date")
    private Date endDate;
    //送货类型
    @Column (name = "delivery_type")
    private int deliveryType;
    //物流公司标识
    @Column (name = "logistics_id", length = 32)
    private String logisticsId;
    //订单备注信息
    @Column (name = "remark", length = 128)
    private String remark;
    //订单商品信息
    @OneToMany (cascade = {CascadeType.PERSIST, CascadeType.REMOVE}, fetch = FetchType.EAGER, orphanRemoval = true)
    @JoinColumn (name = "order_id")
    private List<WareItem> items;
    //订单优惠信息
    @OneToMany (cascade = {CascadeType.PERSIST, CascadeType.REMOVE}, fetch = FetchType.EAGER, orphanRemoval = true)
    @JoinColumn (name = "order_id")
    private List<OrderCoupon> coupons;
    //订单发票信息
    @OneToOne (cascade = {CascadeType.ALL})
    @JoinColumn (name = "order_id")
    private InvoiceInfo invoiceInfo;

    public long getId()
    {
        return id;
    }

    public void setId(long id)
    {
        this.id = id;
    }

    public long getPid()
    {
        return pid;
    }

    public void setPid(long pid)
    {
        this.pid = pid;
    }

    public String getType()
    {
        return type;
    }

    public void setType(String type)
    {
        this.type = type;
    }

    public String getOwnerType()
    {
        return ownerType;
    }

    public void setOwnerType(String ownerType)
    {
        this.ownerType = ownerType;
    }

    public String getOwnerId()
    {
        return ownerId;
    }

    public void setOwnerId(String ownerId)
    {
        this.ownerId = ownerId;
    }

    public int getPayType()
    {
        return payType;
    }

    public void setPayType(int payType)
    {
        this.payType = payType;
    }

    public double getTotalPrice()
    {
        return totalPrice;
    }

    public void setTotalPrice(double totalPrice)
    {
        this.totalPrice = totalPrice;
    }

    public double getPaymentPrice()
    {
        return paymentPrice;
    }

    public void setPaymentPrice(double paymentPrice)
    {
        this.paymentPrice = paymentPrice;
    }

    public double getSellerPrice()
    {
        return sellerPrice;
    }

    public void setSellerPrice(double sellerPrice)
    {
        this.sellerPrice = sellerPrice;
    }

    public double getFreightPrice()
    {
        return freightPrice;
    }

    public void setFreightPrice(double freightPrice)
    {
        this.freightPrice = freightPrice;
    }

    public double getSellerDiscount()
    {
        return sellerDiscount;
    }

    public void setSellerDiscount(double sellerDiscount)
    {
        this.sellerDiscount = sellerDiscount;
    }

    public int getStatus()
    {
        return status;
    }

    public void setStatus(int status)
    {
        this.status = status;
    }

    public long getConsigneeAddress()
    {
        return consigneeAddress;
    }

    public void setConsigneeAddress(long consigneeAddress)
    {
        this.consigneeAddress = consigneeAddress;
    }

    public Date getCreationDate()
    {
        return creationDate;
    }

    public void setCreationDate(Date creationDate)
    {
        this.creationDate = creationDate;
    }

    public Date getUpdateDate()
    {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate)
    {
        this.updateDate = updateDate;
    }

    public Date getEndDate()
    {
        return endDate;
    }

    public void setEndDate(Date endDate)
    {
        this.endDate = endDate;
    }

    public int getDeliveryType()
    {
        return deliveryType;
    }

    public void setDeliveryType(int deliveryType)
    {
        this.deliveryType = deliveryType;
    }

    public String getLogisticsId()
    {
        return logisticsId;
    }

    public void setLogisticsId(String logisticsId)
    {
        this.logisticsId = logisticsId;
    }

    public String getRemark()
    {
        return remark;
    }

    public void setRemark(String remark)
    {
        this.remark = remark;
    }

    public List<WareItem> getItems()
    {
        return items;
    }

    public void setItems(List<WareItem> items)
    {
        this.items = items;
    }

    public List<OrderCoupon> getCoupons()
    {
        return coupons;
    }

    public void setCoupons(List<OrderCoupon> coupons)
    {
        this.coupons = coupons;
    }

    public InvoiceInfo getInvoiceInfo()
    {
        return invoiceInfo;
    }

    public void setInvoiceInfo(InvoiceInfo invoiceInfo)
    {
        this.invoiceInfo = invoiceInfo;
    }
}
